import random


def get_participants():
    
    participants = []
    print("请输入参与者名单，每行一个名字，输入空行结束：")
    while True:
        name = input().strip()
        if name == "":
            if not participants:
                print("警告：您还没有输入任何参与者，请至少输入一个名字！")
                continue
            else:
                break
        participants.append(name)
    return participants


def draw_winners(participants, num_winners=1):

    if not participants:
        return []

    winners = random.sample(participants, min(num_winners, len(participants)))
    return winners


def display_results(winners):


    if not winners:
        print("没有有效的获奖者！")
        return

    print("\n获奖者名单：")
    for i, winner in enumerate(winners, 1):
        print(f"{i}. {winner}")


def main():
    print("=== 简易抽奖系统 ===")


    participants = get_participants()


    while True:
        try:
            num_winners = int(input("\n请输入要抽取的获奖人数："))
            if num_winners <= 0:
                print("获奖人数必须大于0！")
                continue
            if num_winners > len(participants):
                print(f"警告：获奖人数超过参与者人数({len(participants)})")
            break
        except ValueError:
            print("请输入有效的数字！")


    winners = draw_winners(participants, num_winners)


    display_results(winners)


if __name__ == "__main__":
    main()